﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
  public  class KetNoi_KhenThuong:KetNoiCoSoDuLieu
    {
      public void them_KhenThuong(string @TenLoaiKT, string @NgayQD, string @MaNV, string @NoiDung, string @HinhThuc)
      {
          SqlCommand cmd = new SqlCommand("dbo.insert_KhenThuong", cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          SqlParameter  p = new SqlParameter("@TenLoaiKT", TenLoaiKT);
          cmd.Parameters.Add(p);
          p = new SqlParameter("@NgayQD",Convert.ToDateTime( NgayQD));
          cmd.Parameters.Add(p);
          p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
          cmd.Parameters.Add(p);
          p = new SqlParameter("@NoiDung", NoiDung);
          cmd.Parameters.Add(p);
          p = new SqlParameter("@HinhThuc", HinhThuc);
          cmd.Parameters.Add(p);
          cmd.ExecuteNonQuery();
      }
      public void sua_KhenThuong(string @MaLoaiKT, string @TenLoaiKT, string @NgayQD, string @MaNV, string @NoiDung, string @HinhThuc)
      {
          SqlCommand cmd = new SqlCommand("dbo.update_KhenThuong", cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          SqlParameter p = new SqlParameter("@MaLoaiKT",MaLoaiKT);
          cmd.Parameters.Add(p);
          p = new SqlParameter("@TenLoaiKT", TenLoaiKT);
          cmd.Parameters.Add(p);
          p = new SqlParameter("@NgayQD",Convert.ToDateTime( NgayQD));
          cmd.Parameters.Add(p);
          p = new SqlParameter("@MaNV", Convert.ToInt32(MaNV));
          cmd.Parameters.Add(p);
          p = new SqlParameter("@NoiDung", NoiDung);
          cmd.Parameters.Add(p);
          p = new SqlParameter("@HinhThuc", HinhThuc);
          cmd.Parameters.Add(p);
          cmd.ExecuteNonQuery();
      }
      public void xoa_KhenThuong(string @MaLoaiKT)
      {
          SqlCommand cmd = new SqlCommand("dbo.delete_KhenThuong", cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          SqlParameter p = new SqlParameter("@MaLoaiKT",MaLoaiKT);
          cmd.Parameters.Add(p);
          cmd.ExecuteNonQuery();
      }
      public DataTable LoadDuLieu()
      {
          DataTable dt = new DataTable();
          SqlCommand cmd = new SqlCommand("LoadKhenThuong",cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          da.Fill(dt);
          return dt;
      }
      public DataTable TraCuu_MaKhenThuong(string @MaLoaiKT)
      {
          DataTable dt = new DataTable();
          SqlCommand cmd = new SqlCommand("TraCuu_MaKhenThuong", cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@MaLoaiKT",MaLoaiKT);
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          da.Fill(dt);
          return dt;
      }
      public DataTable TraCuu_MaNhanVienKhenThuong(string @MaNV)
      {
          DataTable dt = new DataTable();
          SqlCommand cmd = new SqlCommand("TraCuu_MaNhanVienKhenThuong", cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@MaNV",MaNV);
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          da.Fill(dt);
          return dt;
      }
      public DataTable Load_KhenThuong()
      {
          DataTable dt = new DataTable();
          SqlCommand cmd = new SqlCommand("Load_tbl_KhenThuong",cnn);
          cmd.CommandType = CommandType.StoredProcedure;
          SqlDataAdapter da = new SqlDataAdapter(cmd);
          da.Fill(dt);
          return dt;
      }
    }
}
